 /*
  *@(#)SpiderDBConnection.java	20 Sept. 2000
  *
  * Copyright: MetaPlus Inc & Inquiry Management Systems Ltd.  2000
  *
  * This software is the proprietary information of MetaPlus Inc & 
  * Inquiry Management Systems Ltd.  
  * Use is subject to license terms.
  */

package com.ims.iaa;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.LinkedList;
import java.util.List;

import com.ims.iaa.AD.AdDataLink;
import com.ims.iaa.AD.FlashLink;
import com.ims.iaa.AD.ImgLink;


/**
  * This remote interface defines the services provided by the "Spider
  * Database" object.
  * 
  * Add storeFlashLink() by ShengMeng Bai at 2004-07-24
  * 
  *
  * @see SpiderDBConnectionImpl
  * 
  * @author Anthony Zhang
  * @author ShengMeng Bai
  *
  * @version 1.00, 25 Sept. 2000
  * @version 2.00, 24 JUL. 2004
  *
  */
public interface SpiderDBConnection  extends Remote {

	public int storeAdDataLink(AdDataLink objAdDataLink, LocalRequest lReq, String sThreadName) throws RemoteException;
	
	//++changsheng 2006-5-16
	/**
	 * for save cache ad data link
	 */
	public void saveCacheAdDataLink(ImgLink objAdDataLink, LocalRequest lReq, String sThreadName) throws RemoteException;
	/**
     * do the fast compare
     * @return
     */
    public int doFastCompare(ImgLink ad,LocalRequest lReq,String sThreadName) throws RemoteException;
    public int doPreCompare(ImgLink ad,LocalRequest lReq,String sThreadName) throws RemoteException;
 
    /**
     * do really compare
     */
    public void doCompare(ImgLink ad ,int thisImpressionID ,String sThreadName) throws RemoteException ;
	//--
    
	/*public int getSiteIdFromDB(String url, String sThreadName) throws RemoteException;*/
	
	/*public int getCompanyIdFromDB(String url, String sThreadName) throws RemoteException;	*/
	
	public int getRequestIdFromDB(LocalRequest lReq, String sThreadName)  throws RemoteException;
	
	public int getSearchIdFromDB(LocalRequest lReq, String sThreadName) throws RemoteException;
	
	public void updateRequestStartTime(int searchId,Timestamp startTime, String sThreadName) throws RemoteException;
	
	public void updateRequestEndTime(int searchId,Timestamp endTime, String sThreadName) throws RemoteException; 	
	
	public void updateRequestSpiderName(int searchId,String name) throws RemoteException; 	
	
	public void updateRequestState(int searchId,int state, String sThreadName) throws RemoteException;
	
	public LinkedList loadCustomerRequest(String sThreadName) throws RemoteException; 
	public LinkedList loadAgency(String sThreadName, int intRequestID) throws RemoteException;
	//	added by yxy 2008-05-14, for intCriteria calculation
	public LinkedList loadAdSize(String sThreadName, int intRequestID) throws RemoteException;
	/**
	 * Some impression state isn't successful, 
	 * so, need re-connect to the resouce, call this method
	 * to the the bad impression.
	 * @param iMaxTimes, the max retry times, if the times lagger than iMaxTimes, will don't get the data
	 * @param iInterval, the retry time interval, unit is hours, 
	 * 
	 * @return AdDataLink object list, 
	 * 			this AdDataLink object has been initial, can be call parse(List) method directly.
	 */
	public List getReConnectImp(int iMaxTimes, int iInterval, String sThreadName) throws RemoteException;
	/**
	 * After re-connect the resouce, we must through this method update the database
	 * @see #getReConnectImp(int, int)
	 * @param objAdDataLink AdDataLink object, the object's m_iOldImpressionID and m_iOldImageID must > 0
	 * @throws RemoteException
	 */
	public void updateAdDataLink(AdDataLink objAdDataLink, String sThreadName) throws RemoteException;
	/**
	 * Some flash URL isn't get before decompile, so get it to decompile
	 * @return FlashLink object list.
	 * @throws RemoteException
	 */
	public List getUnparsedFlashImp(String sThreadName) throws RemoteException;
	/**
	 * After parse the flash URL, we must through this method update the database
	 * @see #getUnparsedFlashImp(String)
	 * @param flashLink FlashLink object, the object's m_iOldImpressionID must > 0
	 * @throws RemoteException
	 */
	public void updateFlashURL(FlashLink flashLink, String sThreadName) throws RemoteException;
	/**
	 * Get the proxy setting from database.
	 * 
	 * @param sMachineName, current machine name
	 * @param sThreadName, current thread name
	 * @return ProxySetting object, if get, else return null.
	 * 
	 * @throws RemoteException
	 */
	public ProxySetting getProxy(String sMachineName, String sThreadName) throws RemoteException;
}